dom_ready(function()
{
	var oCon = document.getElementById('cut_intro');	
	var textH = oCon.offsetHeight;

	if(textH>240)
	{
		var open_con = document.createElement('a');
		open_con.state = 0;
		open_con.innerHTML = '全部展开'+' <i class="icon-angle-down">'+'</i>';
		open_con.href = "javascript:;";
		open_con.className = 'p_expand';
		oCon.appendChild(open_con);
		oCon.style.height = 290+'px';			

		open_con.onclick = function()
		{
			this.blur();
			if(open_con.state==0)
			{
				oCon.style.height = textH+50+'px';
				open_con.innerHTML = '收起'+' <i class="icon-angle-up">'+'</i>';
				open_con.state = 1;
			}
			else
			{
				oCon.style.height = 290+'px';
				open_con.innerHTML = '全部展开'+' <i class="icon-angle-down">'+'</i>';
				open_con.state = 0;
			}
		}		
	}

	var aText = getByClass(document, 'text_intro');

	for(var i=0;i<aText.length;i++)
	{
		if(aText[i].offsetHeight>50)
		{
			aText[i].style.height = 40+'px';
			var oEllip = document.createElement('span');
			oEllip.innerHTML = '…';
			oEllip.className = 'ellip';
			aText[i].appendChild(oEllip);
		}
	}
})

function getByClass(oParent, sClass)
{
	if(oParent.getElementsByClassName)
	{
		return oParent.getElementsByClassName(sClass);
	}
	
	var aEle=oParent.getElementsByTagName('*');
	
	var re=new RegExp('\\b'+sClass+'\\b');
	var result=[];
	
	for(var i=0;i<aEle.length;i++)
	{
		if(re.test(aEle[i].className))
		{
			result.push(aEle[i]);
		}
	}	
	return result;
}


function dom_ready(fn){
	if(document.addEventListener){  
		document.addEventListener('DOMContentLoaded',function(){
			fn && fn();	
		},false);	
	}else{
		document.onreadystatechange=function(){
			if(document.readyState=='complete'){
				fn && fn();	
			}	
		}	
	}	
}


function styleCode()
{
    if (typeof disableStyleCode != "undefined")
    {
        return;
    }

    var a = false;

    $("pre code").each(function()
    {
        if (!$(this).hasClass("prettyprint"))
        {
            $(this).addClass("prettyprint");
            a = true
        }
    });

    if (a) { prettyPrint() }
}
;
